package mornd.test2;


import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author: mornd
 * @dateTime: 2023/5/6 - 14:31
 */

public class Demo {
    public static void main(String[] args) {
        Target t = new Target();

        Target p = new MyProxy(new MethodInterceptor() {
            @Override
            public Object intercept(Object o, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
                System.out.println("before");
                //return method.invoke(t, args);
                //return methodProxy.invoke(t, args);
                return methodProxy.invokeSuper(o, args);
            }
        });

        p.save();
        p.save(1);
        p.save(2L);
    }
}
